/* ========================================================================== */
/*   GameHandler.h                                                            */
/*   (c) 2012 Team 7 Hogeschool Utrecht ICT TI                                */
/*		Lars Stolwijk, Gerben Boot, Guido van Hienen, Marcel Boelen			  */
/*                                                                            */
/*   Responsible for handling the entire game. Reacts from incoming signals   */
/*		from OperationController, Health and GameTime.		 				  */
/* ========================================================================== */

#ifndef __GameHandler
#define __GameHandler

#include "pRTOS.h"

#include "GameController.h"
#include "GameTime.h"
#include "IntroduceGame.h"
#include "SoundController.h"
#include "Health.h"
#include "Config.h"

class GameTime;
class SoundController;
class Health;
class IntroduceGame;
class GameController;

class GameHandler : public RTOS::task {
	public:	
		//Constructor
		GameHandler(int prio, SoundController * soundController, GameTime * gameTime, Health * health);
		
		void ZeroGameTime();
		void Death();
		void StartGame();
		void StopGame();
		
	private:
		enum State { WAITING,INTRODUCING, RUNNING, FINISHING, BEINGDEATH };
		State CurrentState;

		RTOS::timer GameTaskTimer;
		RTOS::flag ZeroGameTimeFlag;
		RTOS::flag DeathFlag;
		RTOS::flag StartGameFlag;
		RTOS::flag StopGameFlag;

		SoundController * theSoundController;
		GameTime * theGameTime;
		Health * theHealth;
		IntroduceGame * introduceGame;
		GameController * gameController;
		
		void main();
};

#endif
